#!/usr/bin/sh

set -e

mysqldump -h ${JIANMU_HOST} -P ${JIANMU_PORT} -u${JIANMU_USERNAME} -p${JIANMU_PASSWORD} ${JIANMU_DATABASE} ${JIANMU_TABLES} > ${JM_SHARE_DIR}/${JIANMU_DATABASE}.sql

echo 'result file:'
echo -e "{\n\"sql_path\": \"${JM_SHARE_DIR}/${JIANMU_DATABASE}.sql\"\n}" > /usr/result_file
cat /usr/result_file